#pragma once
#include<iostream>
#include<cstdlib>
#include<cassert>
using namespace std;
class Stack
{
public:
	Stack(int capacity = 4, int top = 0)
	{
		_top = top;
		_capacity = capacity;
		int* pp = (int*)malloc(sizeof(int) * 4);
		assert(pp);
		_p = pp;
	}
	void StackPush(int x);
	void StackPop();
	bool StackEmpty();
	void StackExpansion()
	{
		if (_top == _capacity)
		{
			int* tem = (int*)realloc(_p, sizeof(int) * 2 * _capacity);
			assert(tem);
			_p = tem;
			_capacity = 2 * _capacity;
		}
	}
	void StackPrint()
	{
		for (int i = 0; i < _top; i++)
			cout << _p[i] << "->";
		cout << endl;
	}
private:
	int* _p;
	int _top;
	int _capacity;
};
